package com.aiyige.base.eventbus;

import android.os.Parcel;
import android.os.Parcelable;

import com.aiyige.page.publish.guarantee.model.GuaranteeItem;
import com.aiyige.page.publish.selecttraingcard.model.TraingCard;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by zhuyakun on 2017/12/6.
 */

public class EventSelectTraingCard implements Parcelable {
    public static final int RESULT_OK = 1;
    public static final int RESULT_CANCEL = 2;
    int resultCode;
    List<TraingCard> traingCardList;

    public EventSelectTraingCard() {
    }

    private EventSelectTraingCard(Builder builder) {
        setResultCode(builder.resultCode);
        setTraingCardList(builder.traingCardList);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public int getResultCode() {
        return resultCode;
    }

    public void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public List<TraingCard> getTraingCardList() {
        return traingCardList;
    }

    public void setTraingCardList(List<TraingCard> traingCardList) {
        this.traingCardList = traingCardList;
    }

    public static final class Builder {
        private int resultCode;
        private List<TraingCard> traingCardList;

        private Builder() {
            resultCode = RESULT_CANCEL;
            traingCardList = new LinkedList<>();
        }

        public Builder resultCode(int resultCode) {
            this.resultCode = resultCode;
            return this;
        }

        public Builder traingCardList(List<TraingCard> traingCardList) {
            this.traingCardList = traingCardList;
            return this;
        }

        public EventSelectTraingCard build() {
            return new EventSelectTraingCard(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.resultCode);
        dest.writeTypedList(this.traingCardList);
    }

    protected EventSelectTraingCard(Parcel in) {
        this.resultCode = in.readInt();
        this.traingCardList = in.createTypedArrayList(TraingCard.CREATOR);
    }

    public static final Parcelable.Creator<EventSelectTraingCard> CREATOR = new Parcelable.Creator<EventSelectTraingCard>() {
        @Override
        public EventSelectTraingCard createFromParcel(Parcel source) {
            return new EventSelectTraingCard(source);
        }

        @Override
        public EventSelectTraingCard[] newArray(int size) {
            return new EventSelectTraingCard[size];
        }
    };
}
